﻿#region Using directives

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

#endregion

namespace MetaHeuristics
{
    public sealed class ColorMath
    {
        private ColorMath()
        {}

        public static Color Add(Color c0, Color c1)
        {
            return Color.FromArgb(
                Math.Min(255, Math.Max(0, c0.A+c1.A)),
                Math.Min(255, Math.Max(0, c0.R+c1.R)),
                Math.Min(255, Math.Max(0, c0.G+c1.G)),
                Math.Min(255, Math.Max(0, c0.B+c1.B))                 
                );
        }

        public static Color Combine(Color c0, float alpha, Color c1)
        {
            float oneMinusAlpha = 1-alpha;
            return Color.FromArgb(
                (int)(oneMinusAlpha*c0.A + alpha * c1.A),
                (int)(oneMinusAlpha*c0.R + alpha * c1.R),
                (int)(oneMinusAlpha*c0.G + alpha * c1.G),
                (int)(oneMinusAlpha * c0.B + alpha * c1.B)
                );
        }
    }
}
